home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- branch ;
- access ;
- symbols sprited:1.3.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.3
- date 92.06.07.18.10.48; author kupfer; state Exp;
- branches 1.3.1.1;
- next 1.2;
-
- 1.2
- date 92.04.21.15.23.29; author kupfer; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 92.04.19.16.58.14; author kupfer; state Exp;
- branches 1.1.1.1;
- next ;
-
- 1.1.1.1
- date 92.06.07.18.13.23; author kupfer; state Exp;
- branches ;
- next ;
-
- 1.3.1.1
- date 92.06.07.18.14.10; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @Benchmark program that exercises copyin.
- @
-
-
- 1.3
- log
- @Add support for the other copy tests (copy out, Vm_MakeAccessible in
- and out).
- @
- text
- @/* Benchmark to test copyin/copyout performance. */
- /* $Header: /sprite/src/benchmarks/copyin/RCS/copyin.c,v 1.2 92/04/21 15:23:29 kupfer Exp Locker: kupfer $ */
-
- #include <sprite.h>
- #include <option.h>
- #include <stdio.h>
- #include <spriteTime.h>
- #include <status.h>
- #include <sys/time.h>
- #include <unistd.h>
- #include <vmTypes.h>
-
- #define BUFFER_SIZE 8192 /* see Vm_Cmd; XXX should go into VM header
- * file */
-
- char *buf; /* Buffer to copy in from. */
-
- int copySize[] = {0, 10, 100, 1024, 4096, 8192}; /* various amounts to copy */
- int numSizes = sizeof(copySize) / sizeof(int);
-
- int iterations = 10000; /* number of iterations for each copy size */
-
- int spoilCOW = 0; /* write to the buffer to prevent COW from
- * giving optimistic results */
- int useMakeAccessible = 0; /* use Vm_MakeAccessible & bcopy instead of
- * copyin/out */
- int copyout = 0; /* copy kernel->user instead of vice versa */
-
- Option optionArray[] = {
- {OPT_DOC, NULL, NULL,
- "Exercise Sprite's copyin routine by passing various amounts\n\
- from a dummy buffer to the kernel and reporting the elapsed time."},
- {OPT_TRUE, "cow", (Address)&spoilCOW,
- "Prevent copy-on-write from improving the numbers"},
- {OPT_INT, "iter", (Address)&iterations,
- "Number of times to copy the buffer for each copy amount"},
- {OPT_TRUE, "ma", (Address)&useMakeAccessible,
- "Use Vm_MakeAccessible instead of Vm_CopyIn"},
- {OPT_TRUE, "out", (Address)©out,
- "Do copyout instead of copyin"},
- };
- int numOptions = Opt_Number(optionArray);
-
- void WriteToBuffer();
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- register int i;
- Time startTime, endTime, totalTime;
- int sizeIndex;
- ReturnStatus status;
- int command; /* "copyin" versus "make accessible" */
- char *operation; /* printable name of operation */
-
- (void)Opt_Parse(argc, argv, optionArray, numOptions, 0);
- buf = valloc(BUFFER_SIZE);
- if (buf == NULL) {
- fprintf(stderr, "copyin: no memory.\n");
- exit(1);
- }
- if (useMakeAccessible) {
- if (copyout) {
- operation = "MakeAccessible (out)";
- command = VM_DO_MAKE_ACCESS_OUT;
- } else {
- operation = "MakeAccessible (in)";
- command = VM_DO_MAKE_ACCESS_IN;
- }
- } else {
- if (copyout) {
- operation = "Vm_CopyOut";
- command = VM_DO_COPY_OUT;
- } else {
- operation = "Vm_CopyIn";
- command = VM_DO_COPY_IN;
- }
- }
-
- for (sizeIndex = 0; sizeIndex < numSizes; ++sizeIndex) {
- status = Vm_Cmd(VM_SET_COPY_SIZE, copySize[sizeIndex]);
- if (status != SUCCESS) {
- fprintf(stderr, "Can't set copy size to %d: %s\n",
- copySize[sizeIndex], Stat_GetMsg(status));
- exit(1);
- }
- totalTime = time_ZeroSeconds;
- gettimeofday((struct timeval *)&startTime,0);
- for (i = 0; i < iterations; i++) {
- status = Vm_Cmd(command, buf);
- if (status != SUCCESS) {
- fprintf(stderr, "Can't copy %d bytes: %s\n",
- copySize[sizeIndex], Stat_GetMsg(status));
- exit(1);
- }
- if (spoilCOW) {
- WriteToBuffer(BUFFER_SIZE, buf);
- }
- }
- gettimeofday((struct timeval *)&endTime,0);
- Time_Subtract(endTime, startTime, &totalTime);
- printf("Using %s: copy %4d bytes %d times: %2d.%03d sec\n",
- operation, copySize[sizeIndex], iterations,
- totalTime.seconds, totalTime.microseconds/1000);
- }
- }
-
- void
- WriteToBuffer(length, buffer)
- int length; /* bytes in buffer */
- char *buffer; /* buffer to write to */
- {
- char *cPtr;
-
- for (cPtr = buffer; cPtr < buffer + length; cPtr += 1024) {
- *cPtr = 'a';
- }
- }
- @
-
-
- 1.3.1.1
- log
- @Branch for Sprite server.
- @
- text
- @d2 1
- a2 1
- /* $Header: /sprite/src/benchmarks/copyin/RCS/copyin.c,v 1.3 92/06/07 18:10:48 kupfer Exp $ */
- @
-
-
- 1.2
- log
- @Valloc the buffer.
- @
- text
- @d2 1
- a2 1
- /* $Header: /sprite/src/benchmarks/copyin/RCS/copyin.c,v 1.1 92/04/19 16:58:14 kupfer Exp Locker: kupfer $ */
- d25 3
- d37 4
- d54 2
- d63 17
- d91 1
- a91 1
- status = Vm_Cmd(VM_DO_COPY_IN, buf);
- d93 1
- a93 1
- fprintf(stderr, "Can't do copyin of %d bytes: %s\n",
- d103 2
- a104 2
- printf("copy %4d bytes %d times: %2d.%03d sec\n",
- copySize[sizeIndex], iterations,
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d2 1
- a2 1
- /* $Header: /sprite/src/benchmarks/template/RCS/t.c,v 1.2 92/04/10 15:31:37 kupfer Exp $ */
- d10 1
- d16 1
- a16 1
- char buf[BUFFER_SIZE]; /* Buffer to copy in from. */
- d49 5
- @
-
-
- 1.1.1.1
- log
- @Initial version for sprited.
- @
- text
- @d2 1
- a2 1
- /* $Header: /user5/kupfer/spriteserver/src/benchmarks/copyin/RCS/copyin.c,v 1.2 92/04/24 00:03:56 kupfer Exp $ */
- a9 1
- #include <unistd.h>
- d12 2
- a13 1
- char *buf;
- d15 2
- a47 5
- buf = valloc(VM_DO_COPY_MAX_SIZE);
- if (buf == NULL) {
- fprintf(stderr, "copyin: no memory.\n");
- exit(1);
- }
- d50 6
- d59 1
- a59 1
- status = Vm_Cmd(VM_DO_COPY_IN, copySize[sizeIndex], buf);
- d66 1
- a66 1
- WriteToBuffer(VM_DO_COPY_MAX_SIZE, buf);
- @
-